﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IL2LogParser
{
    /// <summary>
    /// Defines the Player Statistics Class.
    /// </summary>
    class PlayerStats
    {
        public PlayerStats()
        {
            PlayerAction = new List<PlayerActions>();
        }

        public string PlayerName { get; set; }
        public string PlayerPlane { get; set; }
        public string Loadout { get; set; }
        public string Fuel { get; set; }
        public DateTime FlightStart { get; set; }
        public DateTime FlightEnd { get; set; }
        public List<PlayerActions> PlayerAction { get; set; }
        public bool WasKilled { get; set; }

        public void SaveData(string fileToSave)
        {
            System.IO.StreamWriter file = new System.IO.StreamWriter(String.Format("{0}.sql", fileToSave), true);

            foreach (PlayerActions playerAction in PlayerAction)
            {

                string outputString = String.Format("INSERT PreProcessEvents SELECT '{0}','{1}','{2}',{3},'{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}',null\n", fileToSave, this.PlayerName, this.PlayerPlane, this.Loadout, this.Fuel, this.FlightStart, this.FlightEnd, this.WasKilled.ToString(), playerAction.GameAction, playerAction.FlightTimeSeconds, playerAction.XCoord, playerAction.YCoord, playerAction.attackerUser, playerAction.attackerUSerObjectType,playerAction.ActionTime);
                file.Write(outputString);

            }
            file.Close();
        }

    }
}
